package principle.singleResponsibility;

/**
 * @author lcy
 * @date 2024/7/12 17:17
 */
public class Responsibility2 {

    public static void main(String[] args) {
        RoadVehicle roadVehicle = new RoadVehicle();
        roadVehicle.run("汽车");
        roadVehicle.run("火车");
        WaterVehicle waterVehicle = new WaterVehicle();
        waterVehicle.run("轮船");
        AirVehicle airVehicle = new AirVehicle();
        airVehicle.run("飞机");
    }
}
/*
 *  1.遵守了单一职责
 *  2. 改动很大，类分解了，同时修改了客户端
 *  3. 改进：直接修改Vehicle类，改动的代码比较少 方案三
 * */
class RoadVehicle{
    public void run(String vehicle){
        System.out.println(vehicle + "在地上跑");
    }
}

class AirVehicle{
    public void run(String vehicle){
        System.out.println(vehicle + "在天上飞");
    }
}


class WaterVehicle{
    public void run(String vehicle){
        System.out.println(vehicle + "在水上游");
    }
}
